﻿using System;

using CommunityServer.Controls;

using CSLive.LiveID;

namespace CSLive.Controls
{
    /// <summary>
    /// Chameleon control to stop the standard community server logout control from rendering if the user is signed in via LiveID
    /// </summary>
    public class LiveLoginDisplayCondition : ConditionBase

    {
        /// <summary>
        /// Returns false if the user is signed in via Windows Live ID
        /// Returns true if the user is signed in via Community server
        /// </summary>
        public override bool Result
        {
            get
            {
                var loginLink = CSControlUtility.Instance().FindControl( this, "liveidloginlink" ) as LoginLink;

                //Hide the control if the livelogin state is Logged In
                if ( loginLink != null && loginLink.State == State.In )
                    return true;

                return false;
            }
        }
    }
}